package jp.mixi.android.sdk.hackathon.entity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

public class Friends {
    private List<People> list;
    private int startIndex;
    private int itemsPerPage;
    private int totalResults;

    public Friends(String src) {

        try {
            JSONObject root = new JSONObject(src);
            JSONArray array = root.getJSONArray("entry");
            int length = array.length();
            list = new ArrayList<People>();
            for (int i = 0; i < length; i++) {
                list.add(new People(array.getJSONObject(i)));
            }
            startIndex = root.getInt("startIndex");
            itemsPerPage = root.getInt("itemsPerPage");
            totalResults = root.getInt("totalResults");

        } catch (JSONException e) {
            throw new IllegalArgumentException("not json", e);
        }
    }

    public List<People> getPeoples() {
        return list;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public int getItemsPerPage() {
        return itemsPerPage;
    }

    public int getTotalResults() {
        return totalResults;
    }

}
